<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>

<body class="gray-bg">

	<div class="container-div ui-layout-center">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="plan-constraint-form">
	                <input type="hidden" id="parentId" name="parentId">
					<div class="select-list">
						<ul>
							<li>
								约束名称：<input type="text" name="planCstrObj"/>
							</li>
							<li class="select-time">
								<label>更新时间： </label>
								<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
								<span>-</span>
								<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
							</li>
						</ul>
						<ul style="text-align:right">
							<li>
								<!--<button class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</button>-->
								<a class="btn btn-success btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-success btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<button  class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="plan:constraint:add">
	                <i class="fa fa-plus"></i> 新增
	            </button>
	             <a class="btn btn-success btn-edit disabled" onclick="$.operate.edit()" shiro:hasPermission="plan:constraint:edit">
		            <i class="fa fa-edit"></i> 修改
		        </a>
	            <a class="btn btn-danger btn-del disabled" onclick="$.operate.removeAll()" shiro:hasPermission="plan:constraint:remove">
	                <i class="fa fa-remove"></i> 删除
	            </a>
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
	<div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
	<script th:inline="javascript">
		var editFlag = [[${@permission.hasPermi('plan:constraint:edit')}]];
		var removeFlag = [[${@permission.hasPermi('plan:constraint:remove')}]];
		var objDatas = [[${@dict.getType('plan_constraint_obj')}]];
		var ruleDatas = [[${@dict.getType('plan_constraint_rule')}]];
		var joinDatas = [[${@dict.getType('plan_join_syscheck')}]];

		var roleDatas = [[${@dict.getType('sys_user_project_role')}]];
		var hwLevelDatas = [[${@dict.getType('sys_hw_level')}]];
		var regionDatas = [[${@dict.getType('sys_user_region')}]];
		var workYearDatas = [[${@dict.getType('plan_work_year')}]];
		var joinYearDatas = [[${@dict.getType('plan_join_year')}]];
		var achDatas = [[${@dict.getType('plan_achievement_score')}]];

		var prefix = ctx + "plan/constraint";

		$(function() {
			$('body').layout({ west__size: 185 });
			queryConstraintList();
		});

		function queryConstraintList() {
		    var options = {
		        url: prefix + "/list",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        sortName: "planCstrUpdateTime",
		        sortOrder: "desc",
		        modalName: "约束配置",
		        search: false,
		        showExport: false,
		        columns: [{
		            checkbox: true
		        },
		        {
		            field: 'planCstrId',
		            title: '约束ID'
		        },
		        {
		            field: 'planCstrName',
		            title: '约束名称'
		        },
		        {
		            field: 'planCstrObj',
		            title: '约束对象',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(objDatas, value);
		            }
		        },
		        {
		            field: 'planCstrRule',
		            title: '约束规则',
		            align: 'center',
		            formatter: function(value, row, index) {
		            	return $.table.selectDictLabel(ruleDatas, value);
		            }
		        },
		        {
		            field: 'planCstrValue',
		            title: '约束键值',
		            align: 'center',
		            formatter: function(value, row, index) {
		                if(row.planCstrObj == 1){
		                    return $.table.selectDictLabel(roleDatas, value);
		                }
		                else if(row.planCstrObj == 2){
		                    return $.table.selectDictLabel(hwLevelDatas, value);
		                }
		                else if(row.planCstrObj == 3){
		                    return $.table.selectDictLabel(regionDatas, value);
		                }
		                else if(row.planCstrObj == 4){
		                    return $.table.selectDictLabel(workYearDatas, value);
		                }
		                else if(row.planCstrObj == 5){
		                    return $.table.selectDictLabel(joinYearDatas, value);
		                }
		                else if(row.planCstrObj == 6){
		                    return $.table.selectDictLabel(achDatas, value);
		                }
		            }
		        },
		        <!--{-->
		            <!--field: 'planJoinSyscheck',-->
		            <!--title: '参与系统审核',-->
		            <!--align: 'center',-->
		            <!--formatter: function(value, row, index) {-->
		            	<!--return $.table.selectDictLabel(joinDatas, value);-->
		            <!--}-->
		        <!--},-->
		        {
		            field: 'planCstrUpdateTime',
		            title: '约束更新时间',
		            sortable: true
		        },
		        {
		            field: 'userName',
		            title: '更新人'
		        },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
							actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" style="margin:3px;" href="#" onclick="$.operate.edit(\'' + row.planCstrId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
							actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" style="margin:3px;" href="#" onclick="$.operate.remove(\'' + row.planCstrId + '\')"><i class="fa fa-remove"></i>删除</a> ');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		}

	</script>
</body>
</html>